package com.lg.spi.main;

import com.lg.spi.service.DemoSPI;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * 加载配置文件
 *
 * @author by Mr. Li 2020/11/20 21:36
 */
public class MainApplication {

    public static void main(String[] args) {
        ServiceLoader<DemoSPI> serviceLoader = ServiceLoader.load(DemoSPI.class);

        Iterator<DemoSPI> iterator = serviceLoader.iterator();
        while (iterator != null && iterator.hasNext()) {
            DemoSPI demoSPI = iterator.next();
            System.out.println("class:" + demoSPI.getClass().getName() + "---" + demoSPI.sayHi("小刚"));
        }

    }

}
